/* Copyright (C) Noel Llopis, 2001. 
 * All rights reserved worldwide.
 *
 * This software is provided "as is" without express or implied
 * warranties. You may freely copy and compile this source into
 * applications you distribute provided that the copyright text
 * below is included in the resulting source code, for example:
 * "Portions Copyright (C) Noel Llopis, 2001"
 */
//-----------------------------------------------------------------------------
//
//  DeprecationMgr.h
//
/**      \class  DeprecationMgr
//      Tally usage of deprecated functions and report at end of execution.
//
//      Noel Llopis  --  11/20/2000
*/
//-----------------------------------------------------------------------------


#ifndef __DEPRECATION_H__
#define __DEPRECATION_H__

// Identifier was truncated to '255' characters in the debug information
#pragma warning( disable:4786 )  


#include <string>
#include <map>
#include <set>


#if defined(_DEBUG)
#if defined(WIN32)
#define DEPRECATE(a,b) { \
		void * fptr;	\
		_asm { mov fptr, ebp }	\
		DeprecationManager::GetInstance()->AddDeprecatedFunction(a, b, fptr); \
	}
#else
#define DEPRECATE(a,b)
#endif
#else
#define DEPRECATE(a,b)
#endif

#if defined(_DEBUG)
#if defined(WIN32)
#define NOT_IMPLEMENTED(a) {	\
		void * fptr;			\
		_asm { mov fptr, ebp }	\
		NotImplementedManager::GetInstance()->AddNotImplementedFunction(a, fptr); \
	}
#else
#define NOT_IMPLEMENTED(a)
#endif
#else
#define NOT_IMPLEMENTED(a)
#endif

class NotImplementedManager
{
  public:
	static NotImplementedManager * GetInstance ( void );

	~NotImplementedManager ( void );
	
	bool AddNotImplementedFunction( const char * FunctionName,
									const void * FramePtr);
									
  private:
	struct NotImplementedFunction
	{
		const char *	FunctionName;
		std::set<int>	CalledFrom;
	};
	
	NotImplementedManager ( void );
	std::map<const char *, NotImplementedFunction> m_Functions;
};

class DeprecationManager
{
  public:
	static DeprecationManager * GetInstance ( void );

	~DeprecationManager ( void );

	bool AddDeprecatedFunction ( const char * OldFunctionName, 
								 const char * NewFunctionName,
								 const void * FramePtr );

  private:
	struct DeprecatedFunction
	{
		const char *  OldFunctionName;
		const char *  NewFunctionName;
		std::set<int> CalledFrom;
	};

	DeprecationManager ( void );

	std::map<const char *, DeprecatedFunction> m_Functions;
};


#endif //__DEPRECATION_H__
